package org.jeecg.modules.wangyue.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.wangyue.entity.EvaluateJs;
import org.jeecg.modules.wangyue.entity.UserRoleInfo;
import org.jeecg.modules.wangyue.mapper.EvaluateJsMapper;
import org.jeecg.modules.wangyue.mapper.UserRoleInfoMapper;
import org.jeecg.modules.wangyue.model.res.ResEvaluateJsModel;
import org.jeecg.modules.wangyue.service.IEvaluateJsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 技师评价表
 * @Author: jeecg-boot
 * @Date:   2023-06-30
 * @Version: V1.0
 */
@Service
public class EvaluateJsServiceImpl extends ServiceImpl<EvaluateJsMapper, EvaluateJs> implements IEvaluateJsService {

    @Autowired
    private EvaluateJsMapper evaluateJsMapper;
    @Autowired
    private UserRoleInfoMapper userRoleInfoMapper;


    @Override
    public JSONObject getMyEvaluateJsPage(Page<ResEvaluateJsModel> page, String userId, String userType) {
        JSONObject jsonObject = new JSONObject();
        QueryWrapper<UserRoleInfo> userRoleInfoQueryWrapper = new QueryWrapper<>();
        userRoleInfoQueryWrapper.eq("user_id", userId);
        userRoleInfoQueryWrapper.eq("user_type", userType);
        UserRoleInfo userRoleInfo = userRoleInfoMapper.selectOne(userRoleInfoQueryWrapper);

        jsonObject.put("myName", userRoleInfo.getUserName());
        jsonObject.put("myHeadPic", userRoleInfo.getHeadPicUrl());
        jsonObject.put("evaluateJsList", evaluateJsMapper.queryMyEvaluateJsPage(page, userId, userType));
        return jsonObject;
    }

    @Override
    public IPage<ResEvaluateJsModel> getEvaluateJsPage(Page<ResEvaluateJsModel> page, String jsUserId, String jsUserType) {
        return evaluateJsMapper.queryEvaluateJsPage(page, jsUserId, jsUserType);
    }
}
